#define GLOBAL_CPP
#include "worklistplugin_global.h"
#include <QObject>


QString sex2trSex(const QString &sex)
{
    if (sex.contains('M', Qt::CaseInsensitive)) return QObject::tr("M");
    else if (sex.contains('F', Qt::CaseInsensitive)) return QObject::tr("F");
    else return QObject::tr("O");
}

QString age2trAge(const QString &age)
{
    QString unit = age.right(1);
    if (unit == "Y" || unit == "y") {
        return age.left(age.size()-1) + QObject::tr("Years");
    } else if (unit == "M" || unit == "m") {
        return age.left(age.size()-1) + QObject::tr("Months");
    } else if (unit == "W" || unit == "w") {
        return age.left(age.size()-1) + QObject::tr("Weeks");
    } else if (unit == "D" || unit == "d") {
        return age.left(age.size()-1) + QObject::tr("Days");
    } else {
        return age;
    }
}

QString trSex2Sex(const QString &trsex)
{
    if (trsex == QObject::tr("M")) return QString("M");
    else if (trsex == QObject::tr("F")) return QString("F");
    else return QString("O");
}

QTime formatDicomTime(const QString &timeStr)
{
    if (timeStr.contains(".")) {
        return QTime::fromString(timeStr, TIME_DICOM_FORMAT_MS);
    } else {
        return QTime::fromString(timeStr, TIME_DICOM_FORMAT);
    }
}
